package com.guaju.yueshangLife.widget;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.widget.FrameLayout;

import com.guaju.yueshangLife.R;
import com.guaju.yueshangLife.databinding.RefundLineBinding;

public class RefundLine extends FrameLayout {
    public static final int STATUS_ONE = 0;
    public static final int STATUS_TWO = 1;
    public static final int STATUS_THREE = 2;

    private LayoutInflater layoutInflater;
    private RefundLineBinding binding;

    public RefundLine(Context context) {
        super(context);
        init();
    }

    public RefundLine(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {
        layoutInflater = LayoutInflater.from(getContext());
        binding = DataBindingUtil.inflate(layoutInflater, R.layout.refund_line, null, false);
        addView(binding.getRoot());
    }

    public void setStatus(int status) {
        switch (status) {
            case STATUS_ONE:
                enableOne();
                break;
            case STATUS_TWO:
                enableTwo();
                break;
            case STATUS_THREE:
                enableThree();
                break;
            default:
                enableNone();
                break;
        }

    }

    private void enableNone() {
        binding.one.setDotLight(false);
        binding.one.setRightEnable(false);
        binding.two.setLeftEnable(false);
        binding.two.setRightEnable(false);
        binding.two.setDotLight(false);
        binding.three.setLeftEnable(false);
        binding.three.setDotLight(false);
    }

    private void enableThree() {
        binding.one.setDotLight(true);
        binding.one.setRightEnable(true);
        binding.two.setLeftEnable(true);
        binding.two.setRightEnable(true);
        binding.two.setDotLight(true);
        binding.three.setLeftEnable(true);
        binding.three.setDotLight(true);
    }

    private void enableTwo() {
        binding.one.setDotLight(true);
        binding.one.setRightEnable(true);
        binding.two.setLeftEnable(true);
        binding.two.setRightEnable(false);
        binding.two.setDotLight(true);
        binding.three.setLeftEnable(false);
        binding.three.setDotLight(false);
    }

    private void enableOne() {
        binding.one.setDotLight(true);
        binding.one.setRightEnable(false);
        binding.two.setLeftEnable(false);
        binding.two.setRightEnable(false);
        binding.two.setDotLight(false);
        binding.three.setLeftEnable(false);
        binding.three.setDotLight(false);
    }

}
